package cn.kxlove.controller;

import cn.kclove.service.ItemParamItemService;
import cn.kxlove.util.TaotaoResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 郑开心
 * @date 16/1/31
 */
@Controller
@RequestMapping("/item/param/item")
public class ItemParamItemController {

    @Autowired
    private ItemParamItemService itemParamItemService;

    @RequestMapping("/showItem/{itemId}")
    public String showItemParam(@PathVariable Long itemId, Model model) {
        String string = itemParamItemService.getItemParamByItemId(itemId);
        model.addAttribute("itemParam", string);
        return "item";
    }

    @RequestMapping("/query/{itemId}")
    @ResponseBody
    public TaotaoResult query(@PathVariable long itemId){
        return itemParamItemService.queryItemParamByItemIdry(itemId);
    }
}
